package com.twu.biblioteca;

import java.util.ArrayList;

public class Library {
    private ArrayList<Book> bookList;

    Library(){
        bookList = new ArrayList<Book>();
    }

    Library(Book[] bookArray){
        bookList = new ArrayList<Book>();
        for(Book book : bookArray)
            add(book);
    }

    public void add(Book[] books)
    {
        for(Book book : books)
            add(book);
    }

    public void add(Book book){
        bookList.add(book);
    }

    public void printBooks() {
        for(Book book : bookList)
            book.print();
    }

    public String attemptToReserve(String requestedBook) {
        if(canReserve(requestedBook))
            return "Enjoy the book!";
        return "Sorry we don't have that book yet.";
    }

    public boolean canReserve(String requestedBook){
        for(Book book : bookList)
            if(book.isTitle(requestedBook))
                return book.checkOut();
        return false;
    }
}
